package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.AttentionMapper;
import com.mapper.ProjectMapper;
import com.pojo.Attention;
import com.service.AttentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AttentionServiceImpl implements AttentionService {
    @Autowired
    private AttentionMapper attentionMapper;
    @Autowired
    private ProjectMapper projectMapper;
    @Override
    public PageInfo<Attention> selectAll(int pageNum, long userId) {
        PageHelper.startPage(pageNum,3);
        List<Attention> attentions = attentionMapper.selectAll(userId);
        PageInfo pageInfo = new PageInfo(attentions);
        return pageInfo;
    }

    @Override
    public int deleteAtten(long userId, long projectId) {
        int i1 = projectMapper.updateAttenjian(projectId);
        int i = attentionMapper.deleteAtten(userId, projectId);
        return i;
    }

    @Override
    public int addAtten(long userId, long projectId) {
        int i1 = projectMapper.updateAttenjia(projectId);
        int i = attentionMapper.addAtten(userId, projectId);
        return i;
    }

    @Override
    public Attention selectAtten(long userId, long projectId) {
        return attentionMapper.selectAtten(userId,projectId);
    }
}
